#include <iostream>
#include <vector>

void parse(std::string line, std::vector<std::string> &str_vec)
{
    int pos = 0;
    while (pos < line.size())
    {
        std::string tmp;
        while (pos < line.size() && line[pos] != ' ')
        {
            tmp.push_back(line[pos]);
            pos++;
        }
        pos++;
        str_vec.push_back(tmp);
    }
}

int main()
{
    int rec_num;
    std::cin >> rec_num;
    std::cin.ignore();

    std::vector<bool> result;
    for (int i = 0; i < rec_num; i++)
    {
        int absent = 0;
        int cont_late = 0;
        int wrong_state = 0;

        std::string line;
        std::getline(std::cin, line);
        std::vector<std::string> str_vec;
        parse(line, str_vec);
        // std::cout << str_vec.size() << std::endl;
        std::vector<int> wrong_vec(str_vec.size() + 1, 0);
        for (int j = 0; j < str_vec.size(); j++)
        {
            if (str_vec[j] == "absent")
            {
                absent++;
                break;
            }
            if (str_vec[j] != "present")
            {
                wrong_vec[j + 1] = wrong_vec[j] + 1;
            }
            if (j > 0 && (str_vec[j - 1] == "late" || str_vec[j - 1] == "leaveearly" || str_vec[j] == "late" || str_vec[j] == "leaveearly"))
            {
                cont_late++;
                break;
            }
            if (j > 6 && (wrong_vec[j + 1] - wrong_vec[j - 6] > 3))
            {
                wrong_state++;
                break;
            }
        }

        if (wrong_state == 0 && absent == 0 && cont_late == 0)
        {
            result.push_back(true);
        }
        else
        {
            result.push_back(false);
        }
    }

    for (int i = 0; i < result.size() - 1; i++)
    {
        if (result[i])
        {
            std::cout << "true ";
        }
        else
        {
            std::cout << "false ";
        }
    }

    if (result.back())
    {
        std::cout << "true" << std::endl;
    }
    else
    {
        std::cout << "false" << std::endl;
    }

    return 0;
}